import { createRouter, createWebHashHistory } from 'vue-router'

const home = () =>
    import ('views/home/home.vue')
const cart = () =>
    import ('views/cart/cart.vue')
const profile = () =>
    import ('views/profile/profile.vue')
const category = () =>
    import ('views/category/category.vue')
const detail = () =>
    import ('views/detail/detail.vue')


const routes = [{
        path: '/',
        redirect: 'home',
        meta: {
            keepAlive: true //设置页面是否需要使用缓存
        },
    }, {
        path: '/home',
        component: home,
        meta: {
            keepAlive: true //设置页面是否需要使用缓存
        },
    },
    {
        path: '/category',
        component: category
    },
    {
        path: '/cart',
        component: cart
    },
    {
        path: '/profile',
        component: profile
    },
    {
        path: '/detail/:iid',
        component: detail
    }
]

const router = createRouter({
    history: createWebHashHistory(),
    routes
})

export default router